Skip to content

[C] Reject a wire blockLength shorter than the fixed fields of the acting version - #1177

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:c-wire-block-length-lower-bound
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:c-wire-block-length-lower-bound

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

Generated C decoders take the message and group blockLength from the wire and read fixed fields at their schema offsets, so a frame whose blockLength is shorter than those fields, with the buffer ending accordingly, makes the field accessors read past the buffer.

_wrap_for_decode and _wrap_for_decode now return NULL with errno E100 or E108 for a blockLength below the extent of the fields present at the acting version. The minimum is per version, so older versions still decode, including composites that gained a member in a later version, and empty groups are not checked. A decoder that passes its own schema version as the acting version, rather than the version from the header, now rejects shorter blocks from older senders. Generators.minBlockLengthExpression is shared with the C++ fix and identical in both PRs.

Part of #969.

Verified: CWireBlockLengthTest fails on master (3 of 5 tests) and passes here, and MinBlockLengthExpressionTest covers the composite case; sbe-tool checkstyle and test, cppbuild and cppbuild --debug-build --sanitise-build pass.

…ting version.

<msg>_wrap_for_decode and <group>_wrap_for_decode return NULL with E100 or
E108 below the extent of the fields present at the acting version. The
minimum is per version because older versions have shorter blocks, so do
not compare against <msg>_sbe_block_length(). Empty groups are not checked.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant